# 导入模块
import requests
from bs4 import BeautifulSoup
# 定义地址
url = "http://www.zongheng.com/rank/details.html?rt=1&d=1"
# 读取地址
response = requests.get(url)
# 用bs4以htm的方式解析
soup = BeautifulSoup(response.text, "html.parser")
# 输出显示地址内容
# print(response.text)
# print(soup.title)   # 网页检查里面的head，title，body，div....
res = soup.find_all(class_="rank_d_b_name")

for i in res:
    # i的类型是soup可用点标签的类型取出内容
    print(i.a.string)  # a的文本模式

number = soup.find_all(class_="rank_d_b_rank")   # 月票
# print(number[0])
# print(len(number))
# print(res)
# 修改网页编码并修改
# print(response,apparent_enconding)
for j in number:
    # 获取月票与排名
    # print(j.div.string)
    # 把tap中的子对象换成list
    print(j.contents[3].contents[0])
